/* 
 * File:   BookingControl.cpp
 * Author: Neo Siong Wei
 * 
 * Created on February 11, 2014, 7:11 PM
 */

#include "BookingControl.h"
#include "MailControl.h"

BookingControl::BookingControl() {

    ifstream infile;
    infile.open("BookingData.txt", ios::in);

    //BookingData's variable.
    int bookingID;
    string status, userID, add, town, city, postal, fName, lName, title, special;
    long fDate, sDate, bDate;

    //PackageData's variable.
    char hType;
    int uID, pType, slot, cost;
    string loc;
    PackageData temp;

    char tempstr[300];

    while (!infile.eof()) {
        infile.getline(tempstr, 300);
        char *ptr = strtok(tempstr, "\n,");

        while (ptr != NULL) {
            hType = *ptr;
            ptr = strtok(NULL, "\n,");

            uID = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            loc = ptr;
            ptr = strtok(NULL, "\n,");

            pType = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            slot = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            cost = atoi(ptr);
            ptr = strtok(NULL, "\n,");
            //End of PackageData

            temp.setCapacity(slot);
            temp.setCost(cost);
            temp.setDestName(loc);
            temp.setHType(pType);
            temp.setPType(hType);
            temp.setPackID(uID);

            userID = ptr;
            ptr = strtok(NULL, "\n,");

            bookingID = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            status = ptr;
            ptr = strtok(NULL, "\n,");

            title = ptr;
            ptr = strtok(NULL, "\n,");

            fName = ptr;
            ptr = strtok(NULL, "\n,");

            lName = ptr;
            ptr = strtok(NULL, "\n,");

            add = ptr;
            ptr = strtok(NULL, "\n,");

            town = ptr;
            ptr = strtok(NULL, "\n,");

            city = ptr;
            ptr = strtok(NULL, "\n,");

            postal = ptr;
            ptr = strtok(NULL, "\n,");

            fDate = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            sDate = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            special = ptr;
            ptr = strtok(NULL, "\n,");

            bDate = atoi(ptr);
            ptr = strtok(NULL, "\n,");

            BookingData temp1(bookingID, status, userID, temp, add, town,
                    city, postal, fName, lName, title,
                    fDate, sDate, special, bDate);

            booking_Vector.push_back(temp1);
        }
    }
    infile.close();
}

BookingControl::~BookingControl() {

    ofstream outfile;
    outfile.open("BookingData.txt", ios::out);

    for (unsigned int i = 0; i < booking_Vector.size(); i++) {
        outfile << booking_Vector[i].getPD_pType() << ","
                << booking_Vector[i].getPD_ID() << ","
                << booking_Vector[i].getPD_DestName() << ","
                << booking_Vector[i].getPD_hType() << ","
                << booking_Vector[i].getPD_capacity() << ","
                << booking_Vector[i].getPD_cost() << ","
                << booking_Vector[i].getUserID() << ","
                << booking_Vector[i].getBookingID() << ","
                << booking_Vector[i].getStatus() << ","
                << booking_Vector[i].getTitle() << ","
                << booking_Vector[i].getFName() << ","
                << booking_Vector[i].getLName() << ","
                << booking_Vector[i].getAdd() << ","
                << booking_Vector[i].getTown() << ","
                << booking_Vector[i].getCity() << ","
                << booking_Vector[i].getPostal() << ","
                << booking_Vector[i].getFDate() << ","
                << booking_Vector[i].getSDate() << ","
                << booking_Vector[i].getSpecial() << ","
                << booking_Vector[i].getBDate() << "\r\n";
    }
    outfile.close();
}

string BookingControl::encrypt(string pw) {
    char *ptr = &pw[0];

    while (*ptr != '\0') {
        *ptr += 3;
        ptr++;
    }

    return pw;
}

string BookingControl::decrypt(string pw) {
    char *ptr = &pw[0];

    while (*ptr != '\0') {
        *ptr -= 3;
        ptr++;
    }

    return pw;
}

void BookingControl::PrintBanner() {
    int temp;
    string banner;

    ifstream infile;
    infile.open("Banner2.txt", ios::in);

    while (infile >> temp) {
        getline(infile, banner);
        cout << banner << endl;
    }
    infile.close();
}

string BookingControl::ReturnDays(int hType) {
    switch (hType) {
        case 0: return "3D 2N";
            break;
        case 1: return "7D 6N";
            break;
        case 2: return "14D13N";
            break;
        default: return "28D27N";
    }
}

string BookingControl::ReturnPName(int hType) {
    switch (hType) {
        case 0: return "Small Adv";
            break;
        case 1: return "Tier Adv";
            break;
        case 2: return "Great Adv";
            break;
        default: return "Really Big ADV!";
    }
}

string BookingControl::ReturnDate(long longDate) {
}

void BookingControl::view_Booking(char role, string userID) {

    if (role == 'C')
        PrintBanner();

    cout << endl;
    cout << left << setw(4) << "NO."
            << left << setw(7) << "DAY"
            << left << setw(6) << "COST"
            << left << setw(10) << "BDATE"
            << left << setw(34) << "LOCATION"
            << left << setw(1) << "PASSENGER" << endl
            << left << setw(4) << "   "
            << left << setw(13) << "DATE1"
            << left << setw(10) << "DATE2"
            << left << setw(34) << "SPECIAL NEEDS"
            << left << setw(1) << "STATUS" << endl
            << left << setw(4) << "   "
            << left << setw(13) << "ADDRESS" << endl << endl;

    switch (role) {
        case 'C': for (unsigned int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getUserID() == userID) {
                    cout << left << setw(4) << booking_Vector[i].getBookingID()
                            << left << setw(7) << ReturnDays(booking_Vector[i].getPD_hType())
                            << left << setw(6) << booking_Vector[i].getPD_cost()
                            << left << setw(10) << booking_Vector[i].getBDate()
                            << left << setw(34) << booking_Vector[i].getPD_DestName()
                            << left << setw(1) << booking_Vector[i].getFName()
                            << " " << booking_Vector[i].getLName() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFDate()
                            << left << setw(10) << booking_Vector[i].getSDate()
                            << left << setw(34) << booking_Vector[i].getSpecial()
                            << left << setw(1) << booking_Vector[i].getStatus() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFullAddress() << endl << endl;
                }
            }
            cout << endl;
            break;
        case 'B': for (unsigned int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getStatus() == "submitted" || booking_Vector[i].getStatus() == "edited") {
                    cout << left << setw(4) << booking_Vector[i].getBookingID()
                            << left << setw(7) << ReturnDays(booking_Vector[i].getPD_hType())
                            << left << setw(6) << booking_Vector[i].getPD_cost()
                            << left << setw(10) << booking_Vector[i].getBDate()
                            << left << setw(34) << booking_Vector[i].getPD_DestName()
                            << left << setw(1) << booking_Vector[i].getFName()
                            << " " << booking_Vector[i].getLName() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFDate()
                            << left << setw(10) << booking_Vector[i].getSDate()
                            << left << setw(34) << booking_Vector[i].getSpecial()
                            << left << setw(1) << booking_Vector[i].getStatus() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFullAddress() << endl << endl;
                }
            }
            cout << endl;
            break;

        case 'H': for (unsigned int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getStatus() == "checked" || booking_Vector[i].getStatus() == "waitingList") {
                    cout << left << setw(4) << booking_Vector[i].getBookingID()
                            << left << setw(7) << ReturnDays(booking_Vector[i].getPD_hType())
                            << left << setw(6) << booking_Vector[i].getPD_cost()
                            << left << setw(10) << booking_Vector[i].getBDate()
                            << left << setw(34) << booking_Vector[i].getPD_DestName()
                            << left << setw(1) << booking_Vector[i].getFName()
                            << " " << booking_Vector[i].getLName() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFDate()
                            << left << setw(10) << booking_Vector[i].getSDate()
                            << left << setw(34) << booking_Vector[i].getSpecial()
                            << left << setw(1) << booking_Vector[i].getStatus() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFullAddress() << endl << endl;
                }
            }
            cout << endl;
            break;

        default: for (unsigned int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getStatus() == "paymentReq") {
                    cout << left << setw(4) << booking_Vector[i].getBookingID()
                            << left << setw(7) << ReturnDays(booking_Vector[i].getPD_hType())
                            << left << setw(6) << booking_Vector[i].getPD_cost()
                            << left << setw(10) << booking_Vector[i].getBDate()
                            << left << setw(34) << booking_Vector[i].getPD_DestName()
                            << left << setw(1) << booking_Vector[i].getFName()
                            << " " << booking_Vector[i].getLName() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFDate()
                            << left << setw(10) << booking_Vector[i].getSDate()
                            << left << setw(34) << booking_Vector[i].getSpecial()
                            << left << setw(1) << booking_Vector[i].getStatus() << endl
                            << left << setw(4) << "   "
                            << left << setw(13) << booking_Vector[i].getFullAddress() << endl << endl;
                }
            }
            cout << endl;
    }
}

void BookingControl::edit_Booking(char role, string userID) {

    int choice, choice1, choice2;
    string title, fName, lName;
    string add, town, city, postal;
    string special;

    view_Booking(role, userID);
    cout << endl << "ENTER index number to edit: ";

    while (!(cin >> choice)) {
        cout << "Invalid Choice!!! Renter: ";
        cin.clear();
        cin.ignore(100, '\n');
    }

    switch (role) {
        case 'C': cout << endl;
            cout << "Edit which field?" << endl
                    << " 1) Edit name and title" << endl
                    << " 2) Edit special needs" << endl
                    << " 3) Edit address" << endl << endl
                    << "Your choice: ";

            while (!(cin >> choice1) || !(choice1 >= 1 && choice1 <= 3)) {
                cout << "Invalid Choice!!! Renter: ";
                cin.clear();
                cin.ignore(100, '\n');
            }

            switch (choice1) {
                case 1: cout << endl << "Select your title" << endl
                            << " 1) MR" << endl
                            << " 2) DR" << endl
                            << " 3) SIR" << endl
                            << " 4) MRS" << endl
                            << " 5) MS" << endl
                            << " 6) MDM" << endl << endl
                            << "Your choice: ";

                    while (!(cin >> choice2) || !(choice2 >= 1 && choice2 <= 6)) {
                        cout << "Invalid Choice!!! Renter: ";
                        cin.clear();
                        cin.ignore(100, '\n');
                    }

                    switch (choice2) {
                        case 1: title = "MR";
                            break;
                        case 2: title = "DR";
                            break;
                        case 3: title = "SIR";
                            break;
                        case 4: title = "MRS";
                            break;
                        case 5: title = "MS";
                            break;
                        default: title = "MDM";
                    }

                    cout << endl << "Enter your first name (5 characters)"
                            << endl << "name: " << endl;

                    cin.clear();
                    cin.ignore(80, '\n');

                    while (!getline(cin, fName) || !(fName.size() <= 5 && fName.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }

                    cout << endl << "Enter your last name (15 characters)"
                            << endl << "name: " << endl;

                    while (!getline(cin, lName) || !(lName.size() <= 15 && lName.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }

                    for (int i = 0; i < booking_Vector.size(); i++) {
                        if (booking_Vector[i].getBookingID() == choice)
                            booking_Vector[i].setFullName(title, fName, lName);
                    }
                    break;

                case 2: cout << endl << "Enter new special requirements (20 characters)"
                            << endl << "text: " << endl;

                    cin.clear();
                    cin.ignore(80, '\n');

                    while (!getline(cin, special) || !(special.size() <= 20 && special.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }
                    for (int i = 0; i < booking_Vector.size(); i++) {
                        if (booking_Vector[i].getBookingID() == choice)
                            booking_Vector[i].setSpecial(special);
                    }
                    break;

                default: cout << endl << "Enter your address (10 characters)"
                            << endl << "text: " << endl;

                    cin.clear();
                    cin.ignore(80, '\n');

                    while (!getline(cin, add) || !(add.size() <= 10 && add.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }

                    cout << endl << "Enter your town (20 characters)"
                            << endl << "text: " << endl;

                    while (!getline(cin, town) || !(town.size() <= 20 && town.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }

                    cout << endl << "Enter your city (10 characters)"
                            << endl << "text: " << endl;

                    while (!getline(cin, city) || !(city.size() <= 10 && city.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }

                    cout << endl << "Enter your postal code (8 characters)"
                            << endl << "text: " << endl;

                    while (!getline(cin, postal) || !(postal.size() <= 8 && postal.size() > 0)) {
                        cout << endl << "Invalid!!!" << endl
                                << "Please renter: " << endl;
                    }

                    for (int i = 0; i < booking_Vector.size(); i++) {
                        if (booking_Vector[i].getBookingID() == choice)
                            booking_Vector[i].setAddress(add, town, city, postal);
                    }
            }

            for (int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getBookingID() == choice)
                    booking_Vector[i].setStatus("edited");
            }

            cout << endl << "Booking Updated!!!" << endl;
            break;

        case 'B': cout << endl;
            cout << "Edit to which status?" << endl
                    << " 1) to checked" << endl
                    << " 2) to invalid" << endl
                    << " 3) to incomplete" << endl << endl
                    << "Your choice: ";

            while (!(cin >> choice1) || !(choice1 >= 1 && choice1 <= 3)) {
                cout << "Invalid Choice!!! Renter: ";
                cin.clear();
                cin.ignore(100, '\n');
            }

            for (int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getBookingID() == choice) {
                    if (choice1 == 1)
                        booking_Vector[i].setStatus("checked");
                    else if (choice1 == 2)
                        booking_Vector[i].setStatus("invalid");
                    else
                        booking_Vector[i].setStatus("incomplete");
                }
            }
            cout << endl << "Booking Status Updated!!!" << endl;
            break;

        case 'H': cout << endl;
            cout << "Edit to which status?" << endl
                    << " 1) to waitingList" << endl
                    << " 2) to paymentReq" << endl << endl
                    << "Your choice: ";

            while (!(cin >> choice1) || !(choice1 >= 1 && choice1 <= 2)) {
                cout << "Invalid Choice!!! Renter: ";
                cin.clear();
                cin.ignore(100, '\n');
            }

            for (int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getBookingID() == choice) {
                    if (choice1 == 1)
                        booking_Vector[i].setStatus("waitingList");
                    else {
                        booking_Vector[i].setStatus("paymentReq");
                        mailController m;
                        m.sendMail(1, booking_Vector[i].getUserID());
                    }


                }
            }
            cout << endl << "Booking Status Updated!!!" << endl;
            break;

        default: cout << endl;
            cout << "Edit to which status?" << endl
                    << " 1) to confirmed" << endl
                    << " 2) to cancelled" << endl << endl
                    << "Your choice: ";

            while (!(cin >> choice1) || !(choice1 >= 1 && choice1 <= 2)) {
                cout << "Invalid Choice!!! Renter: ";
                cin.clear();
                cin.ignore(100, '\n');
            }

            for (int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getBookingID() == choice) {
                    if (choice1 == 1)
                        booking_Vector[i].setStatus("confirmed");
                    else {
                        booking_Vector[i].setStatus("cancelled");
                    }
                }
            }
            cout << endl << "Booking Status Updated!!!" << endl;
    }
}

void BookingControl::create_Booking(string userID, PackageControl p) {

    p.ViewPackage('C');

    int id = 1;
    int choice;
    string status = "submitted", user, fName, lName, title;
    string add, town, city, post, special;
    long fDate, sDate, bDate;

    cout << endl;
    cout << "Select package to book: ";

    while (!(cin >> choice) || !(choice >= 1 && choice <= p.packageData.size())) {
        cout << "Invalid Choice!!! Renter: ";
        cin.clear();
        cin.ignore(100, '\n');
    }

    user = userID;
    PackageData PD = p.returnPackage(choice);

    cin.clear();
    cin.ignore(100, '\n');

    cout << endl << "ENTER first name (5 characters) "
            << endl << "Insert: " << endl;

    while (!getline(cin, fName) || !(fName.size() <= 5 && fName.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    cout << endl << "ENTER last name (15 characters) "
            << endl << "Insert: " << endl;

    while (!getline(cin, lName) || !(lName.size() <= 15 && lName.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    cout << endl;
    cout << "Select your title" << endl
            << " 1) Mr" << endl
            << " 2) Dr" << endl
            << " 3) Sir" << endl
            << " 4) Mrs" << endl
            << " 5) Ms" << endl
            << " 6) Mdm" << endl << endl
            << "Your choice: ";

    while (!(cin >> choice) || !(choice >= 1 && choice <= 6)) {
        cout << "Invalid Choice!!! Renter: ";
        cin.clear();
        cin.ignore(100, '\n');
    }

    switch (choice) {
        case 1: title = "Mr";
            break;
        case 2: title = "Dr";
            break;
        case 3: title = "Sir";
            break;
        case 4: title = "Mrs";
            break;
        case 5: title = "Ms";
            break;
        default: title = "Mdm";
    }

    cout << endl << "ENTER your address (10 characters) "
            << endl << "Address: " << endl;

    cin.clear();
    cin.ignore(100, '\n');

    while (!getline(cin, add) || !(add.size() <= 10 && add.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    cout << endl << "ENTER your town (20 characters) "
            << endl << "Town: " << endl;

    while (!getline(cin, town) || !(town.size() <= 20 && town.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    cout << endl << "ENTER your city (10 characters) "
            << endl << "City: " << endl;

    while (!getline(cin, city) || !(city.size() <= 10 && city.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    cout << endl << "ENTER your postage address (8 characters) "
            << endl << "Postage: " << endl;

    while (!getline(cin, post) || !(post.size() <= 8 && post.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    cout << endl << "ENTER first date (8 characters, DDMMYYYY) "
            << endl << "date: " << endl;

    while (!(cin >> fDate) || !(fDate <= 99999999 && fDate >= 00000000)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;

        cin.clear();
        cin.ignore(100, '\n');
    }

    cout << endl << "ENTER second date (8 characters, DDMMYYYY) "
            << endl << "date: " << endl;

    while (!(cin >> sDate) || !(sDate <= 99999999 && sDate >= 00000000)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;

        cin.clear();
        cin.ignore(100, '\n');
    }

    cout << endl << "ENTER todays date (8 characters, DDMMYYYY) "
            << endl << "date: " << endl;

    while (!(cin >> bDate) || !(bDate <= 99999999 && bDate >= 00000000)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;

        cin.clear();
        cin.ignore(100, '\n');
    }

    cout << endl << "ENTER special needs (20 characters, leave nill is none) "
            << endl << "Needs: " << endl;

    while (!getline(cin, special) || !(special.size() <= 20 && special.size() > 0)) {
        cout << endl << "Invalid!!!" << endl
                << "Please renter: " << endl;
    }

    BookingData BDtemp(id, status, user, PD, add, town, city, post, fName, lName, title, fDate, sDate, special, bDate);
    booking_Vector.push_back(BDtemp);

    cout << endl << "Booking Completed!!!" << endl;
}

long BookingControl::del_Booking(char role, string userID) {
    int choice;

    view_Booking(role, userID);

    cout << endl << "ENTER index number to delete: ";

    while (!(cin >> choice)) {
        cout << "Invalid Choice!!! Renter: ";
        cin.clear();
        cin.ignore(100, '\n');
    }

    for (int i = 0; i < booking_Vector.size(); i++) {
        if (booking_Vector[i].getBookingID() == choice)
            booking_Vector[i].setStatus("cancelled");
        mailController m;
        m.sendMail(2, booking_Vector[i].getUserID());
    }
    cout << endl << "Booking is cancelled!!!" << endl;
}

void BookingControl::view_Statistics(PackageControl p) {

    int choice, choice1, packID, total = 0, waitList = 0, payReq = 0, paid = 0;
    float percentage;

    cout << endl;
    cout << "Select view mode" << endl
            << " 1) view 1 package" << endl
            << " 2) view all packages" << endl << endl
            << "Your choice: ";

    while (!(cin >> choice1) || !(choice1 >= 1 && choice1 <= 2)) {
        cout << "Invalid Choice!!! Renter: ";
        cin.clear();
        cin.ignore(100, '\n');
    }

    switch (choice1) {
        case 1: p.ViewPackage('G');

            cout << endl;
            cout << "Select package to view: ";

            while (!(cin >> choice) || !(choice >= 1 && choice <= p.packageData.size())) {
                cout << "Invalid Choice!!! Renter: ";
                cin.clear();
                cin.ignore(100, '\n');
            }

            packID = choice;

            cout << endl;
            cout << left << setw(4) << "NO."
                    << left << setw(15) << "TOTAL BOOKED"
                    << left << setw(15) << "WAITING LIST"
                    << left << setw(15) << "PAYMENT REQ"
                    << left << setw(15) << "CONFIRMED"
                    << left << setw(1) << "% PAID" << endl;

            for (int i = 0; i < booking_Vector.size(); i++) {
                if (booking_Vector[i].getPD_ID() == packID) {
                    if (booking_Vector[i].getStatus() == "confirmed") {
                        paid++;
                        total++;
                    } else if (booking_Vector[i].getStatus() == "waitingList") {
                        waitList++;
                        total++;
                    } else if (booking_Vector[i].getStatus() == "paymentReq") {
                        payReq++;
                        total++;
                    } else
                        if (booking_Vector[i].getStatus() != "cancelled")
                        total++;
                }
            }

            if (total != 0)
                percentage = paid / total;
            else
                percentage = 0;

            cout << endl;
            cout << left << setw(4) << packID
                    << left << setw(15) << total
                    << left << setw(15) << waitList
                    << left << setw(15) << payReq
                    << left << setw(15) << paid
                    << left << setw(1) << percentage << "%" << endl;
            break;

        default: cout << endl;
            cout << left << setw(4) << "NO."
                    << left << setw(15) << "TOTAL BOOKED"
                    << left << setw(15) << "WAITING LIST"
                    << left << setw(15) << "PAYMENT REQ"
                    << left << setw(15) << "CONFIRMED"
                    << left << setw(1) << "% PAID" << endl;

            for (int j = 0; j < p.packageData.size(); j++) {
                paid = 0;
                total = 0;
                payReq = 0;

                for (int i = 0; i < booking_Vector.size(); i++) {
                    if (booking_Vector[i].getPD_ID() == j) {
                        if (booking_Vector[i].getStatus() == "confirmed") {
                            paid++;
                            total++;
                        } else if (booking_Vector[i].getStatus() == "waitingList") {
                            waitList++;
                            total++;
                        } else if (booking_Vector[i].getStatus() == "paymentReq") {
                            payReq++;
                            total++;
                        } else
                            if (booking_Vector[i].getStatus() != "cancelled")
                            total++;
                    }
                }
                if (total != 0)
                    percentage = paid / total;
                else
                    percentage = 0;

                cout << left << setw(4) << j
                        << left << setw(15) << total
                        << left << setw(15) << waitList
                        << left << setw(15) << payReq
                        << left << setw(15) << paid
                        << left << setw(1) << percentage << "%" << endl;
            }
    }


}